package final_package;

public class Test2 {
    public static void main(String[] args) {
        /*
        final  修饰基本数据类型：记录的值不能发生改变
        final  修饰引用数据类型：记录的地址值不能发生改变，内部的属性值还是可以改变的
         */

        final double PI = 3.14;
        //error:  PI = 2;

        //创建对象
        final Student s = new Student("张三", 23);
        //error:  s=new Student();
        s.setName("李四");
        s.setAge(24);
        System.out.println(s.getName() + ", " + s.getAge());

        //数组
        final int[] arr = {1, 2, 3, 4, 5};
        //error:  arr = new int[10];
        arr[0] = 10;
        arr[1] = 20;

        //遍历数组
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
        System.out.println();
    }
}

class Student {
    private String name;
    private int age;

    public Student() {
    }

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }


}